unit uGLBasePage;

interface
uses
  GlScene, GlObjects, GlMaterial,
  uBasePage;
type
  TGLBasePageClass = class of TGLBasePage;
//------------------------------------------------------------------------------
  TGLBasePage = class(TBasePage)
  protected
    fParent: TGLBaseSceneObject;
    fPageDummy: TGlDummyCube;

    Procedure HideComplete(); override;
  protected
    Procedure AddToScene; virtual;
    Procedure RemoveFromScene; virtual;
    Procedure UpdateUnitTime(); override;
    Procedure InitCustomObjects(fMaterialLibrary: TGlMaterialLibrary); virtual;
  public
    Procedure Show; override;
    Procedure InitGLPage(aGlParent: TGLBaseSceneObject; fMaterialLibrary: TGlMaterialLibrary);
  end;
//------------------------------------------------------------------------------
implementation
//------------------------------------------------------------------------------
Procedure TGLBasePage.Show;
begin
  inherited Show;
  AddToScene();
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.HideComplete();
begin
  inherited HideComplete;
  RemoveFromScene();
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.AddToScene;
begin
  if fPageDummy.Parent <> fParent  then
    fParent.AddChild(fPageDummy);
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.RemoveFromScene;
begin
  fParent.Remove(fPageDummy, false);
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.UpdateUnitTime();
begin
  inherited UpdateUnitTime;
  fPageDummy.Material.GetActualPrimaryMaterial().FrontProperties.Diffuse.Alpha := 0.2;
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.InitCustomObjects(fMaterialLibrary: TGlMaterialLibrary); 
begin
end;
//------------------------------------------------------------------------------
Procedure TGLBasePage.InitGLPage(aGlParent: TGLBaseSceneObject; fMaterialLibrary: TGlMaterialLibrary);
begin
  fParent := aGlParent;
  fPageDummy := TGlDummyCube.Create(nil);
  InitCustomObjects(fMaterialLibrary);
end;
//------------------------------------------------------------------------------
end.
